home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / sdoc210.zip / SDSAMPLE.SUB < prev    next >
Text File  |  1993-02-04  |  2KB  |  50 lines

  1. DefInt A-Z
  2. ''  This module deals with discovering how much of a form
  3. ''  gets lost with the border.
  4. ''      **** NB Essential for all VB programmers ****
  5. ''  Written by Peter Fox.  3 Feb 1993
  6. ''      2 Tees Close, Witham, Essex CM8 1LG,England
  7. ''      Domestic tel:  0376 517206
  8. ''      Intnl tel:  +44 376 517206
  9. ''      (Compuserve ID:  100116,1031)
  10. ''  Make the best use of them you can.
  11. Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As Integer
  12. ''  API call works with Win 3.0 provided nIndex <= 35(decimal)
  13. ''  Constants declared with the style SM_...
  14. Const SM_CXSCREEN = 0
  15. Const SM_CYSCREEN = 1
  16. Const SM_CYCAPTION = 4      ' pixels height of a caption bar (also menu bar)
  17. Const SM_CXBORDER = 5       ' pixels width of a frame border (technically non-sizeable!)
  18. Const SM_CYBORDER = 6       ' pixels height of a frame border (technically non-sizeable!)
  19. Const SM_CYMENU = 15
  20. Const SM_CXFULLSCREEN = 16
  21. Const SM_CYFULLSCREEN = 17
  22. Const SM_CXFRAME = 32
  23. Const SM_CYFRAME = 33
  24.  
  25. Function lostframeheightintwips% (withmenu%)
  26. ''  Return the height (in twips) that is lost because the FORM.HEIGHT property
  27. ''  includes the title and borders
  28. ''  If WITHMENU% is true then we have to inclue a (single) menu bar in the
  29. ''  value to be lost.
  30. captionht = GetSystemMetrics(SM_CYCAPTION)          ' system dimensions in pixels
  31. fixborderHt = GetSystemMetrics(SM_CYBORDER)
  32. sizborderHt = GetSystemMetrics(SM_CYFRAME)
  33. stppy = screen.TwipsPerPixelY                       ' conversion factor for this screen
  34.  
  35. If withmenu% Then m = 2 Else m = 1      ' 2 title heights if we have a menu bar
  36. lostheightinpix = (m * (captionht - fixborderHt)) + (2 * sizborderHt)
  37. lostframeheightintwips = lostheightinpix * stppy
  38. End Function
  39.  
  40. Function LostFramewidthintwips% ()
  41. ''  Return the width (in twips) that is lost because the FORM.WIDTH
  42. ''  property includes the borders
  43. sizborderWd = GetSystemMetrics(SM_CXFRAME)      ' pixel width of frame
  44. stppx = screen.TwipsPerPixelX                   ' conversion factor
  45. lostwidthinpix = 2 * sizborderWd
  46. LostFramewidthintwips = lostwidthinpix * stppx
  47.  
  48. End Function
  49.  
  50.